home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Musique / Quod Libet / quodlibet-3.3.0-installer.exe / bin / quodlibet / qltk / information.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2014-12-31  |  23KB  |  646 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.7)
  3.  
  4. import time
  5. from gi.repository import Gtk, Pango
  6. from quodlibet import const
  7. from quodlibet import qltk
  8. from quodlibet import util
  9. from quodlibet.qltk.bookmarks import EditBookmarksPane
  10. from quodlibet.qltk.cover import CoverImage
  11. from quodlibet.qltk.lyrics import LyricsPane
  12. from quodlibet.qltk.window import Window, PersistentWindowMixin
  13. from quodlibet.util import tag, connect_destroy
  14. from quodlibet.util.tags import readable
  15. from quodlibet.util.path import fsdecode, filesize, unexpand
  16.  
  17. def Label(label = None):
  18.     l = Gtk.Label(label = label)
  19.     l.set_selectable(True)
  20.     l.set_alignment(0, 0)
  21.     return l
  22.  
  23.  
  24. def Frame(name, widget):
  25.     f = Gtk.Frame()
  26.     f.set_shadow_type(Gtk.ShadowType.NONE)
  27.     l = Gtk.Label()
  28.     l.set_markup('<u><b>%s</b></u>' % name)
  29.     f.set_label_widget(l)
  30.     a = Gtk.Alignment.new(xalign = 0, yalign = 0, xscale = 1, yscale = 1)
  31.     a.set_padding(3, 0, 12, 0)
  32.     f.add(a)
  33.     a.add(widget)
  34.     return f
  35.  
  36.  
  37. def SW():
  38.     swin = Gtk.ScrolledWindow()
  39.     swin.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
  40.     return swin
  41.  
  42.  
  43. class NoSongs(Gtk.Label):
  44.     
  45.     def __init__(self):
  46.         super(NoSongs, self).__init__(label = _('No songs are selected.'))
  47.         self.title = _('No Songs')
  48.  
  49.  
  50.  
  51. class OneSong(qltk.Notebook):
  52.     
  53.     def __init__(self, library, song):
  54.         super(OneSong, self).__init__()
  55.         vbox = Gtk.VBox(spacing = 12)
  56.         vbox.set_border_width(12)
  57.         self._title(song, vbox)
  58.         self._album(song, vbox)
  59.         self._people(song, vbox)
  60.         self._library(song, vbox)
  61.         self._file(song, vbox)
  62.         sw = SW()
  63.         sw.title = _('Information')
  64.         sw.add_with_viewport(vbox)
  65.         self.append_page(sw)
  66.         lyrics = LyricsPane(song)
  67.         lyrics.title = _('Lyrics')
  68.         self.append_page(lyrics)
  69.         bookmarks = EditBookmarksPane(None, song)
  70.         bookmarks.title = _('Bookmarks')
  71.         bookmarks.set_border_width(12)
  72.         self.append_page(bookmarks)
  73.         connect_destroy(library, 'changed', self._OneSong__check_changed, vbox, song)
  74.  
  75.     
  76.     def __check_changed(self, library, songs, vbox, song):
  77.         if song in songs:
  78.             for c in vbox.get_children():
  79.                 vbox.remove(c)
  80.                 c.destroy()
  81.             
  82.             self._title(song, vbox)
  83.             self._album(song, vbox)
  84.             self._people(song, vbox)
  85.             self._library(song, vbox)
  86.             self._file(song, vbox)
  87.             parent = qltk.get_top_parent(self)
  88.             if parent:
  89.                 parent.set_title(self.title + ' - Quod Libet')
  90.             vbox.show_all()
  91.  
  92.     
  93.     def _title(self, song, box):
  94.         l = Label()
  95.         text = '<big><b>%s</b></big>' % util.escape(song.comma('title'))
  96.         if 'version' in song:
  97.             text += '\n' + util.escape(song.comma('version'))
  98.         l.set_markup(text)
  99.         l.set_ellipsize(Pango.EllipsizeMode.END)
  100.         box.pack_start(l, False, False, 0)
  101.         self.title = song.comma('title')
  102.  
  103.     
  104.     def _album(self, song, box):
  105.         if 'album' not in song:
  106.             return None
  107.         w = None('')
  108.         text = []
  109.         text.append('<i>%s</i>' % util.escape(song.comma('album')))
  110.         if 'date' in song:
  111.             text[-1] += ' (%s)' % util.escape(song.comma('date'))
  112.         secondary = []
  113.         if 'discnumber' in song:
  114.             secondary.append(_('Disc %s') % song['discnumber'])
  115.         if 'discsubtitle' in song:
  116.             secondary.append('<i>%s</i>' % util.escape(song.comma('discsubtitle')))
  117.         if 'tracknumber' in song:
  118.             secondary.append(_('Track %s') % song['tracknumber'])
  119.         if secondary:
  120.             text.append(' - '.join(secondary))
  121.         if 'organization' in song or 'labelid' in song:
  122.             t = util.escape(song.comma('~organization~labelid'))
  123.             text.append(t)
  124.         if 'producer' in song:
  125.             text.append('Produced by %s' % util.escape(song.comma('producer')))
  126.         w.set_markup('\n'.join(text))
  127.         w.set_ellipsize(Pango.EllipsizeMode.END)
  128.         hb = Gtk.HBox(spacing = 12)
  129.         cover = CoverImage()
  130.         cover.set_property('no-show-all', True)
  131.         hb.pack_start(cover, False, True, 0)
  132.         
  133.         def show_cover(cover, success):
  134.             if success:
  135.                 cover.show()
  136.             cover.disconnect(signal_id)
  137.  
  138.         signal_id = cover.connect('cover-visible', show_cover)
  139.         cover.set_song(song)
  140.         hb.pack_start(w, True, True, 0)
  141.         box.pack_start(Frame(tag('album'), hb), False, False, 0)
  142.  
  143.     
  144.     def _people(self, song, box):
  145.         vb = Gtk.VBox()
  146.         if 'artist' in song:
  147.             if len(song.list('artist')) == 1:
  148.                 title = _('artist')
  149.             else:
  150.                 title = _('artists')
  151.             title = util.capitalize(title)
  152.             l = Label(song['artist'])
  153.             l.set_ellipsize(Pango.EllipsizeMode.END)
  154.             vb.pack_start(l, False, True, 0)
  155.         else:
  156.             title = tag('~people')
  157.         for tag_ in [
  158.             'performer',
  159.             'lyricist',
  160.             'arranger',
  161.             'composer',
  162.             'conductor',
  163.             'author']:
  164.             if tag_ in song:
  165.                 l = Label(song[tag_])
  166.                 l.set_ellipsize(Pango.EllipsizeMode.END)
  167.                 if len(song.list(tag_)) == 1:
  168.                     name = tag(tag_)
  169.                 else:
  170.                     name = readable(tag_, plural = True)
  171.             vb.pack_start(Frame(util.capitalize(name), l), False, False, 0)
  172.             continue
  173.         
  174.         performers = { }
  175.         for tag_ in song:
  176.             if 'performer:' in tag_:
  177.                 for person in song[tag_].split('\n'):
  178.                     
  179.                     try:
  180.                         performers[str(person)]
  181.                     except:
  182.                         performers[str(person)] = []
  183.  
  184.                     performers[str(person)].append(util.title(tag_[tag_.find(':') + 1:]))
  185.                 
  186.         if len(performers) > 0:
  187.             performerstr = ''
  188.             for performer in performers:
  189.                 performerstr += performer + ' ('
  190.                 i = 0
  191.                 for part in performers[performer]:
  192.                     if i != 0:
  193.                         performerstr += ', '
  194.                     performerstr += part
  195.                     i += 1
  196.                 
  197.                 performerstr += ')\n'
  198.             
  199.             l = Label(performerstr)
  200.             l.set_ellipsize(Pango.EllipsizeMode.END)
  201.             if len(performers) == 1:
  202.                 name = tag('performer')
  203.             else:
  204.                 name = _('performers')
  205.             vb.pack_start(Frame(util.capitalize(name), l), False, False, 0)
  206.         if not vb.get_children():
  207.             vb.destroy()
  208.         else:
  209.             box.pack_start(Frame(title, vb), False, False, 0)
  210.  
  211.     
  212.     def _library(self, song, box):
  213.         
  214.         def counter(i):
  215.             if i == 0:
  216.                 return _('Never')
  217.             return None('%(n)d time', '%(n)d times', i) % {
  218.                 'n': i }
  219.  
  220.         
  221.         def ftime(t):
  222.             if t == 0:
  223.                 return _('Unknown')
  224.             timestr = None.strftime('%c', time.localtime(t))
  225.             return timestr.decode(const.ENCODING)
  226.  
  227.         playcount = counter(song.get('~#playcount', 0))
  228.         skipcount = counter(song.get('~#skipcount', 0))
  229.         lastplayed = ftime(song.get('~#lastplayed', 0))
  230.         if lastplayed == _('Unknown'):
  231.             lastplayed = _('Never')
  232.         added = ftime(song.get('~#added', 0))
  233.         rating = song('~rating')
  234.         has_rating = '~#rating' in song
  235.         t = Gtk.Table(n_rows = 5, n_columns = 2)
  236.         t.set_col_spacings(6)
  237.         t.set_homogeneous(False)
  238.         table = [
  239.             (_('added'), added, True),
  240.             (_('last played'), lastplayed, True),
  241.             (_('plays'), playcount, True),
  242.             (_('skips'), skipcount, True),
  243.             (_('rating'), rating, has_rating)]
  244.         for l, r, s in enumerate(table):
  245.             l = '<b>%s</b>' % util.capitalize(util.escape(l) + ':')
  246.             lab = Label()
  247.             lab.set_markup(l)
  248.             t.attach(lab, 0, 1, i + 1, i + 2, xoptions = Gtk.AttachOptions.FILL)
  249.             label = Label(r)
  250.             label.set_sensitive(s)
  251.             t.attach(label, 1, 2, i + 1, i + 2)
  252.         
  253.         box.pack_start(Frame(_('Library'), t), False, False, 0)
  254.  
  255.     
  256.     def _file(self, song, box):
  257.         
  258.         def ftime(t):
  259.             if t == 0:
  260.                 return _('Unknown')
  261.             timestr = None.strftime('%c', time.localtime(t))
  262.             return timestr.decode(const.ENCODING)
  263.  
  264.         fn = fsdecode(unexpand(song['~filename']))
  265.         length = util.format_time_long(song.get('~#length', 0))
  266.         if not song.get('~#filesize'):
  267.             pass
  268.         size = util.format_size(filesize(song['~filename']))
  269.         mtime = ftime(util.path.mtime(song['~filename']))
  270.         bitrate = song.get('~#bitrate', 0)
  271.         if bitrate != 0:
  272.             bitrate = _('%d kbps') % int(bitrate)
  273.         else:
  274.             bitrate = False
  275.         t = Gtk.Table(n_rows = 4, n_columns = 2)
  276.         t.set_col_spacings(6)
  277.         t.set_homogeneous(False)
  278.         table = [
  279.             (_('length'), length),
  280.             (_('file size'), size),
  281.             (_('modified'), mtime)]
  282.         if bitrate:
  283.             table.insert(1, (_('bitrate'), bitrate))
  284.         fnlab = Label(fn)
  285.         fnlab.set_ellipsize(Pango.EllipsizeMode.MIDDLE)
  286.         t.attach(fnlab, 0, 2, 0, 1, xoptions = Gtk.AttachOptions.FILL)
  287.         for l, r in enumerate(table):
  288.             l = '<b>%s</b>' % util.capitalize(util.escape(l) + ':')
  289.             lab = Label()
  290.             lab.set_markup(l)
  291.             t.attach(lab, 0, 1, i + 1, i + 2, xoptions = Gtk.AttachOptions.FILL)
  292.             t.attach(Label(r), 1, 2, i + 1, i + 2)
  293.         
  294.         box.pack_start(Frame(_('File'), t), False, False, 0)
  295.  
  296.  
  297.  
  298. class OneAlbum(qltk.Notebook):
  299.     
  300.     def __init__(self, songs):
  301.         super(OneAlbum, self).__init__()
  302.         swin = SW()
  303.         swin.title = _('Information')
  304.         vbox = Gtk.VBox(spacing = 12)
  305.         vbox.set_border_width(12)
  306.         swin.add_with_viewport(vbox)
  307.         songs = sorted(songs)
  308.         self._title(songs, vbox)
  309.         self._album(songs, vbox)
  310.         self._people(songs, vbox)
  311.         self._description(songs, vbox)
  312.         self.append_page(swin)
  313.  
  314.     
  315.     def _title(self, songs, box):
  316.         song = songs[0]
  317.         l = Label()
  318.         l.set_ellipsize(Pango.EllipsizeMode.END)
  319.         text = '<big><b>%s</b></big>' % util.escape(song['album'])
  320.         if 'date' in song:
  321.             text += '\n' + song['date']
  322.         l.set_markup(text)
  323.         box.pack_start(l, False, False, 0)
  324.         self.title = song['album']
  325.  
  326.     
  327.     def _album(self, songs, box):
  328.         text = []
  329.         discs = { }
  330.         for song in songs:
  331.             
  332.             try:
  333.                 discs[song('~#disc')] = int(song['tracknumber'].split('/')[1])
  334.             continue
  335.             except (AttributeError, ValueError, IndexError, KeyError):
  336.                 discs[song('~#disc')] = max([
  337.                     song('~#track', discs.get(song('~#disc'), 0))])
  338.                 continue
  339.             
  340.  
  341.         
  342.         tracks = sum(discs.values())
  343.         discs = len(discs)
  344.         length = sum([ song.get('~#length', 0) for song in songs ])
  345.         if tracks == 0 or tracks < len(songs):
  346.             tracks = len(songs)
  347.         parts = []
  348.         if discs > 1:
  349.             parts.append(ngettext('%d disc', '%d discs', discs) % discs)
  350.         parts.append(ngettext('%d track', '%d tracks', tracks) % tracks)
  351.         if tracks != len(songs):
  352.             parts.append(ngettext('%d selected', '%d selected', len(songs)) % len(songs))
  353.         text.append(', '.join(parts))
  354.         text.append(util.format_time_long(length))
  355.         if 'location' in song:
  356.             text.append(util.escape(song['location']))
  357.         if 'organization' in song or 'labelid' in song:
  358.             t = util.escape(song.comma('~organization~labelid'))
  359.             text.append(t)
  360.         if 'producer' in song:
  361.             text.append(_('Produced by %s') % util.escape(song.comma('producer')))
  362.         w = Label('')
  363.         w.set_ellipsize(Pango.EllipsizeMode.END)
  364.         w.set_markup('\n'.join(text))
  365.         hb = Gtk.HBox(spacing = 12)
  366.         cover = CoverImage()
  367.         cover.set_property('no-show-all', True)
  368.         hb.pack_start(cover, False, True, 0)
  369.         
  370.         def show_cover(cover, success):
  371.             if success:
  372.                 cover.show()
  373.             cover.disconnect(signal_id)
  374.  
  375.         signal_id = cover.connect('cover-visible', show_cover)
  376.         cover.set_song(song)
  377.         hb.pack_start(w, True, True, 0)
  378.         box.pack_start(hb, False, False, 0)
  379.  
  380.     
  381.     def _people(self, songs, box):
  382.         artists = set([])
  383.         performers = set([])
  384.         for song in songs:
  385.             artists.update(song.list('artist'))
  386.             performers.update(song.list('performer'))
  387.         
  388.         artists = sorted(artists)
  389.         performers = sorted(performers)
  390.         if artists:
  391.             if len(artists) == 1:
  392.                 title = _('artist')
  393.             else:
  394.                 title = _('artists')
  395.             title = util.capitalize(title)
  396.             box.pack_start(Frame(title, Label('\n'.join(artists))), False, False, 0)
  397.         if performers:
  398.             if len(artists) == 1:
  399.                 title = _('performer')
  400.             else:
  401.                 title = _('performers')
  402.             title = util.capitalize(title)
  403.             box.pack_start(Frame(title, Label('\n'.join(performers))), False, False, 0)
  404.  
  405.     
  406.     def _description(self, songs, box):
  407.         text = []
  408.         cur_disc = songs[0]('~#disc', 1) - 1
  409.         cur_part = None
  410.         cur_track = songs[0]('~#track', 1) - 1
  411.         for song in songs:
  412.             track = song('~#track', 0)
  413.             disc = song('~#disc', 0)
  414.             part = song.get('part')
  415.             if disc != cur_disc:
  416.                 if cur_disc:
  417.                     text.append('')
  418.                 cur_track = song('~#track', 1) - 1
  419.                 cur_part = None
  420.                 cur_disc = disc
  421.                 if disc:
  422.                     text.append('<b>%s</b>' % _('Disc %s') % disc)
  423.                 
  424.             if part != cur_part:
  425.                 ts = '    ' * bool(disc)
  426.                 cur_part = part
  427.                 if part:
  428.                     text.append('%s<b>%s</b>' % (ts, util.escape(part)))
  429.                 
  430.             cur_track += 1
  431.             ts = '    ' * (bool(disc) + bool(part))
  432.             while cur_track < track:
  433.                 text.append('%s<b>%d.</b> <i>%s</i>' % (ts, cur_track, _('Track unavailable')))
  434.                 cur_track += 1
  435.             text.append('%s<b>%d.</b> %s' % (ts, track, util.escape(song.comma('~title~version'))))
  436.         
  437.         l = Label()
  438.         l.set_markup('\n'.join(text))
  439.         l.set_ellipsize(Pango.EllipsizeMode.END)
  440.         box.pack_start(Frame(_('Track List'), l), False, False, 0)
  441.  
  442.  
  443.  
  444. class OneArtist(qltk.Notebook):
  445.     
  446.     def __init__(self, songs):
  447.         super(OneArtist, self).__init__()
  448.         swin = SW()
  449.         swin.title = _('Information')
  450.         vbox = Gtk.VBox(spacing = 12)
  451.         vbox.set_border_width(12)
  452.         swin.add_with_viewport(vbox)
  453.         self._title(songs, vbox)
  454.         self._album(songs, vbox)
  455.         self.append_page(swin)
  456.  
  457.     
  458.     def _title(self, songs, box):
  459.         l = Label()
  460.         l.set_ellipsize(Pango.EllipsizeMode.END)
  461.         artist = util.escape(songs[0]('artist'))
  462.         l.set_markup('<b><big>%s</big></b>' % artist)
  463.         box.pack_start(l, False, False, 0)
  464.         self.title = songs[0]['artist']
  465.  
  466.     
  467.     def _album(self, songs, box):
  468.         noalbum = 0
  469.         albums = { }
  470.         for song in songs:
  471.             if 'album' in song:
  472.                 albums[song.list('album')[0]] = song
  473.                 continue
  474.             noalbum += 1
  475.         
  476.         albums = [ (song.get('date'), song, album) for album, song in albums.items() ]
  477.         albums.sort()
  478.         
  479.         def format(.0):
  480.             (date, song, album) = .0
  481.             if date:
  482.                 return '%s (%s)' % (album, date[:4])
  483.             return None
  484.  
  485.         covers = [ (a, s.find_cover(), s) for d, s, a in albums ]
  486.         albums = map(format, albums)
  487.         if noalbum:
  488.             albums.append(ngettext('%d song with no album', '%d songs with no album', noalbum) % noalbum)
  489.         l = Label('\n'.join(albums))
  490.         l.set_ellipsize(Pango.EllipsizeMode.END)
  491.         box.pack_start(Frame(_('Selected Discography'), l), False, False, 0)
  492.         covers = [ ac for ac in covers if bool(ac[1]) ]
  493.         t = Gtk.Table(n_rows = 4, n_columns = len(covers) // 4 + 1)
  494.         t.set_col_spacings(12)
  495.         t.set_row_spacings(12)
  496.         added = set()
  497.         for album, cover, song in enumerate(covers):
  498.             if cover.name in added:
  499.                 continue
  500.             cov = CoverImage(song = song)
  501.             cov.get_child().set_tooltip_text(album)
  502.             c = i % 4
  503.             r = i // 4
  504.             t.attach(cov, c, c + 1, r, r + 1, xoptions = Gtk.AttachOptions.EXPAND, yoptions = 0)
  505.             added.add(cover.name)
  506.         
  507.         box.pack_start(t, True, True, 0)
  508.  
  509.  
  510.  
  511. class ManySongs(qltk.Notebook):
  512.     
  513.     def __init__(self, songs):
  514.         super(ManySongs, self).__init__()
  515.         swin = SW()
  516.         swin.title = _('Information')
  517.         vbox = Gtk.VBox(spacing = 12)
  518.         vbox.set_border_width(12)
  519.         swin.add_with_viewport(vbox)
  520.         self._title(songs, vbox)
  521.         self._people(songs, vbox)
  522.         self._album(songs, vbox)
  523.         self._file(songs, vbox)
  524.         self.append_page(swin)
  525.  
  526.     
  527.     def _title(self, songs, box):
  528.         l = Label()
  529.         t = ngettext('%d song', '%d songs', len(songs)) % len(songs)
  530.         l.set_markup('<big><b>%s</b></big>' % t)
  531.         self.title = t
  532.         box.pack_start(l, False, False, 0)
  533.  
  534.     
  535.     def _people(self, songs, box):
  536.         artists = set([])
  537.         none = 0
  538.         for song in songs:
  539.             if 'artist' in song:
  540.                 artists.update(song.list('artist'))
  541.                 continue
  542.             none += 1
  543.         
  544.         artists = sorted(artists)
  545.         num_artists = len(artists)
  546.         if none:
  547.             artists.append(ngettext('%d song with no artist', '%d songs with no artist', none) % none)
  548.         box.pack_start(Frame('%s (%d)' % (util.capitalize(_('artists')), num_artists), Label('\n'.join(artists))), False, False, 0)
  549.  
  550.     
  551.     def _album(self, songs, box):
  552.         albums = set([])
  553.         none = 0
  554.         for song in songs:
  555.             if 'album' in song:
  556.                 albums.update(song.list('album'))
  557.                 continue
  558.             none += 1
  559.         
  560.         albums = sorted(albums)
  561.         num_albums = len(albums)
  562.         if none:
  563.             albums.append(ngettext('%d song with no album', '%d songs with no album', none) % none)
  564.         box.pack_start(Frame('%s (%d)' % (util.capitalize(_('albums')), num_albums), Label('\n'.join(albums))), False, False, 0)
  565.  
  566.     
  567.     def _file(self, songs, box):
  568.         length = 0
  569.         size = 0
  570.         for song in songs:
  571.             length += song.get('~#length', 0)
  572.             
  573.             try:
  574.                 size += filesize(song['~filename'])
  575.             continue
  576.             except EnvironmentError:
  577.                 continue
  578.             
  579.  
  580.         
  581.         table = Gtk.Table(n_rows = 2, n_columns = 2)
  582.         table.set_col_spacings(6)
  583.         table.attach(Label(_('Total length:')), 0, 1, 0, 1, xoptions = Gtk.AttachOptions.FILL)
  584.         table.attach(Label(util.format_time_long(length)), 1, 2, 0, 1)
  585.         table.attach(Label(_('Total size:')), 0, 1, 1, 2, xoptions = Gtk.AttachOptions.FILL)
  586.         table.attach(Label(util.format_size(size)), 1, 2, 1, 2)
  587.         box.pack_start(Frame(_('Files'), table), False, False, 0)
  588.  
  589.  
  590.  
  591. class Information(Window, PersistentWindowMixin):
  592.     
  593.     def __init__(self, library, songs, parent = None):
  594.         super(Information, self).__init__(dialog = False)
  595.         self.set_default_size(400, 400)
  596.         self.enable_window_tracking('quodlibet_information')
  597.         if len(songs) > 1:
  598.             connect_destroy(library, 'changed', self._Information__check_changed)
  599.         if len(songs) > 0:
  600.             connect_destroy(library, 'removed', self._Information__check_removed)
  601.         self._Information__songs = songs
  602.         self._Information__update(library)
  603.         self.set_transient_for(qltk.get_top_parent(parent))
  604.         self.get_child().show_all()
  605.  
  606.     
  607.     def __check_changed(self, library, songs):
  608.         changed = set(songs)
  609.         for song in self._Information__songs:
  610.             if song in changed:
  611.                 self._Information__update(library)
  612.                 break
  613.                 continue
  614.  
  615.     
  616.     def __check_removed(self, library, songs):
  617.         gone = set(songs)
  618.         old = len(self._Information__songs)
  619.         self._Information__songs = (filter,)((lambda s: s not in gone), self._Information__songs)
  620.         if len(self._Information__songs) != old:
  621.             self._Information__update(library)
  622.  
  623.     
  624.     def __update(self, library):
  625.         songs = self._Information__songs
  626.         if self.get_child():
  627.             self.get_child().destroy()
  628.         self._Information__songs = songs
  629.         if not songs:
  630.             self.add(NoSongs())
  631.         elif len(songs) == 1:
  632.             self.add(OneSong(library, songs[0]))
  633.         else:
  634.             tags = [ (s.get('artist'), s.get('album')) for s in songs ]
  635.             (artists, albums) = zip(*tags)
  636.             if min(albums) == max(albums) and albums[0]:
  637.                 self.add(OneAlbum(songs))
  638.             elif min(artists) == max(artists) and artists[0]:
  639.                 self.add(OneArtist(songs))
  640.             else:
  641.                 self.add(ManySongs(songs))
  642.         self.set_title(self.get_child().title + ' - Quod Libet')
  643.         self.get_child().show_all()
  644.  
  645.  
  646.